package com.rslai.base.tool.autotest.mock.util;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.rslai.base.tool.autotest.mock.model.Expectation;

public class JSON {
    private static final Gson gson = new GsonBuilder().registerTypeAdapter(Expectation.class, new PropertyBasedInterfaceMarshal()).create();

    public static <T> T parseObject(String input, Class<? extends T> type) {
        return (T) gson.fromJson(input, type);
    }

    public static String toJSONString(Object o) {
        return com.alibaba.fastjson.JSON.toJSONString(o, new SerializerFeature[]{SerializerFeature.WriteClassName});
    }
}

